#ifndef ELECTRONICSCALETOOL_H
#define ELECTRONICSCALETOOL_H

#include <QObject>
#include "moduleelectronicscaledefine.h"

class ElectronicScaleTool : public QObject
{
    Q_OBJECT
public:
    explicit ElectronicScaleTool(QObject *parent = nullptr);

    // 重量/速度单位转字符串
    static QString toString(electronicscale::WeightUnit unit);
    static QString toString(electronicscale::WeightRateUnit unit);

    // 字符串转重量单位
    static electronicscale::WeightUnit toWeightUnit(const QString &unit);
    // 字符串转速度单位
    static electronicscale::WeightRateUnit toWeightRateUnit(const QString &unit);

    // 重量单位和速度单位互换
    static electronicscale::WeightRateUnit getMatchup(const electronicscale::WeightUnit &weightUnit);
    static electronicscale::WeightUnit getMatchup(const electronicscale::WeightRateUnit &weightRateUnit);

    // 两点间线性插值
    static electronicscale::Sample getLinearWeight(qint64 time, const electronicscale::Sample &start, const electronicscale::Sample &stop);
    // 从样品点中寻找时间time这个点的采样点
    // 如果time在2个样品点中间，则线性插值
    static electronicscale::Sample findWeight(qint64 time, const QList<electronicscale::Sample> &samples);
    // 从样品点中寻找时间time这个点的下标，如果这个时间点在相邻的2个采样点中间，则返回左边的采样点的index
    static int findIndex(qint64 time, const QList<electronicscale::Sample> &samples);

    // 导出重量数据到excel
    static bool exportWeightDataToXlsx(const QString &path, const QList<electronicscale::Sample> &samples);
    // 从excel导入重量数据
    static bool importWeightDataFromXlsx(const QString &path, QList<electronicscale::Sample> &samples);

    // 导出速度数据到excel
    static bool exportIntervalRateToXlsx(const QString &path, const QList<electronicscale::IntervalRate> &rates);
    // 从excel导入速度数据
    static bool importIntervalRateFromXlsx(const QString &path, QList<electronicscale::IntervalRate> &rates);

signals:

};

#endif // ELECTRONICSCALETOOL_H
